﻿Public Class Estadistica
    Dim datos As New datos
    Private Sub Estadistica_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cargarEstadistica1()
        Me.ReportViewer1.RefreshReport()
        cargarEstadistica2()
        Me.ReportViewer2.RefreshReport()
        cargarEstadistica3()
        Me.ReportViewer3.RefreshReport()
    End Sub

    Private Sub cargarEstadistica1()
        Dim sql As String = ""
        sql = "SELECT genero.nombre as data, count(*) AS value"
        sql &= " FROM genero INNER JOIN"
        sql &= " cd ON cd.id_genero = genero.id_genero"
        sql &= " GROUP BY genero.nombre"
        Dim data As New Data.DataTable
        data = (datos.ejecutar_sql(sql))
        DataSetEstadisticasBindingSource.DataSource = data
    End Sub

    Private Sub cargarEstadistica2()
        Dim sql As String
        Sql = "SELECT     tipo_pago.nombre as data, count(*) AS value"
        Sql &= " FROM         (tipo_pago INNER JOIN"
        Sql &= "              factura ON factura.id_tipo_pago = tipo_pago.id_tipo_pago)"
        Sql &= " GROUP BY tipo_pago.nombre"
        Dim data As New Data.DataTable
        Data = datos.ejecutar_sql(Sql)
        DataSetEsta2BindingSource.DataSource = Data
    End Sub

    Private Sub cargarEstadistica3()
        Dim sql As String
        sql = "SELECT     sexo.nombre as data, count(*) AS value"
        sql &= " FROM         (cliente INNER JOIN"
        sql &= "              sexo ON sexo.id_sexo = cliente.id_sexo)"
        sql &= " GROUP BY sexo.nombre"
        Dim data As New Data.DataTable
        data = datos.ejecutar_sql(sql)
        DataSetEsta3BindingSource.DataSource = data
    End Sub
End Class